<?php
error_reporting(E_ALL);

chdir('../');
require_once 'bootstrap.php';

$config = Ezer_Config::createFromPath('config.xml');

Propel::setConfiguration($config->database->toArray());
Propel::initialize();

Ezer_log::setLogger(new StdoutLogger());

// create default user
$user = new SeoUser();
$user->setFirstName('Tan-Tan');
$user->setLastName('Kanarek');
$user->setEmail('tan-tan@simple.co.il');
$user->setStatus(SeoUser::STATUS_ACTIVE);
$user->save();

echo "Added user: " . $user->getId() . "\n";

// create default url
$url = new SeoUrl();
$url->setProtocol('http');
$url->setDomain('www.simple.co.il');
$url->setPath('/');
$url->save();

echo "Added url: " . $url->getId() . "\n";

// create default site
$site = new SeoSite();
$site->setSeoUrl($url);
$site->setMaxPages(10);
$site->save();

echo "Added site: " . $site->getId() . "\n";

// create default site
$sitePath = new SeoSitePath();
$sitePath->setSeoSite($site);
$sitePath->setProtocol('http');
$sitePath->setDomain('*.simple.co.il');
$sitePath->setPath('/*');
$sitePath->save();

echo "Added site path: " . $sitePath->getId() . "\n";

// create default user site connection
$siteUser = new SeoSiteUser();
$siteUser->setRole(SeoSiteUser::ROLE_USER);
$siteUser->setSeoSite($site);
$siteUser->setSeoUser($user);
$siteUser->save();

echo "Added site user: " . $siteUser->getSiteId() . " => " . $siteUser->getUserId() . "\n";

